package com.wb.structual.flyweight;

/**
 * @author 魏彪
 */
public class Client {

    public static void main(String[] args) {
        IgoChessman b1, b2, b3;
        IgoChessmanFactory factory = IgoChessmanFactory.getInstance();


        // 通过享元工厂获取3颗黑子
        b1 = factory.getIgoChessman("black");
        b2 = factory.getIgoChessman("black");
        b3 = factory.getIgoChessman("black");

        System.out.println("判断两颗黑子是否相同: " + (b1 == b2));

        IgoChessman w1, w2;

        w1 = factory.getIgoChessman("white");
        w2 = factory.getIgoChessman("white");

        System.out.println("判断两颗白子是否相同: " + (w1 == w2));

        // 显示棋子
        b1.display(new Coordinates(1, 2));
        b2.display(new Coordinates(3, 4));
        b3.display(new Coordinates(1, 3));

        w1.display(new Coordinates(2, 5));
        w2.display(new Coordinates(2, 4));
    }
}
